Skip to content

Conversation

@daniel-lxs
Copy link
Member

@daniel-lxs daniel-lxs commented Jan 8, 2026

Summary

Fixes ROO-425: OpenRouter + Gemini "parts field" validation error when assistant message has undefined content.

Problem

When assistant messages contain only tool_use blocks (no text), the content field was left as undefined. While OpenAI accepts content: null with tool_calls, Gemini (via OpenRouter) strictly requires every message to have content in the "parts" field.

This caused users to encounter a 400 Bad Request error:

ApiProviderError: Unable to submit request because it must include at least one parts field, which describes the prompt input.

Solution

Use empty string fallback (content ?? "") for assistant message content instead of allowing undefined.

Changes

  • src/api/transform/openai-format.ts: Use content ?? "" instead of content
  • src/api/transform/__tests__/openai-format.spec.ts: Add test case for Gemini compatibility

Testing

  • ✅ All 24 tests pass in openai-format.spec.ts
  • ✅ All 5179 tests pass across the project

Related


Important

Fixes undefined content in assistant messages for Gemini compatibility by using empty string fallback in convertToOpenAiMessages().

  • Behavior:
    • Fixes issue where assistant messages with only tool_use blocks had undefined content, causing errors with Gemini via OpenRouter.
    • Uses content ?? "" to ensure content is never undefined in convertToOpenAiMessages() in openai-format.ts.
  • Testing:
    • Adds test case in openai-format.spec.ts to verify empty string content for Gemini compatibility.
    • All tests pass in openai-format.spec.ts and across the project.

This description was created by Ellipsis for f6304d4. You can customize this summary. It will automatically update as commits are pushed.

…ompatibility

When assistant messages contain only tool_use blocks (no text), the content
field was left as undefined. While OpenAI accepts content: null with tool_calls,
Gemini (via OpenRouter) strictly requires every message to have content.

Changes:
- Use empty string fallback for assistant message content when undefined
- Add test case for Gemini compatibility

Fixes ROO-425
@daniel-lxs daniel-lxs requested review from cte, jr and mrubens as code owners January 8, 2026 23:14
@dosubot dosubot bot added size:M This PR changes 30-99 lines, ignoring generated files. bug Something isn't working labels Jan 8, 2026
@roomote
Copy link
Contributor

roomote bot commented Jan 8, 2026

Rooviewer Clock   See task on Roo Cloud

Review complete. No issues found.

The fix correctly uses content ?? "" to ensure assistant messages never have undefined content, which resolves the Gemini compatibility issue (ROO-425). The implementation is minimal, well-documented, and properly tested.

Mention @roomote in a comment to request specific changes to this pull request or fix all unresolved issues.

@dosubot dosubot bot added the lgtm This PR has been approved by a maintainer label Jan 8, 2026
@hannesrudolph hannesrudolph added the Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. label Jan 8, 2026
@daniel-lxs daniel-lxs moved this from Triage to PR [Needs Review] in Roo Code Roadmap Jan 8, 2026
@hannesrudolph hannesrudolph added PR - Needs Review and removed Issue/PR - Triage New issue. Needs quick review to confirm validity and assign labels. labels Jan 8, 2026
@mrubens mrubens merged commit 9ac4499 into main Jan 9, 2026
27 checks passed
@mrubens mrubens deleted the feature/roo-425-openrouter-gemini-parts-field-validation-error branch January 9, 2026 01:32
@github-project-automation github-project-automation bot moved this from PR [Needs Review] to Done in Roo Code Roadmap Jan 9, 2026
@github-project-automation github-project-automation bot moved this from New to Done in Roo Code Roadmap Jan 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working lgtm This PR has been approved by a maintainer PR - Needs Review size:M This PR changes 30-99 lines, ignoring generated files.

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants